package jeuDeLaVieTest;
/**
 * @author GUIEROU Bertrand
 */
import static org.junit.Assert.*;

import java.io.FileNotFoundException;
import java.io.IOException;
import jeuDeLaVie.Cellule;
import jeuDeLaVie.Jeu;
import jeuDeLaVie.Liste;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;




public class JeuTest {

	public JeuTest() {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public final void testLireFichier() {
		String nom1 = "life.lif";
		Liste b = null;
		int[] univers = {2,4,4,18};
		int[] regle = {11,12,3};
		
		try {
			b = Jeu.lireFichier(nom1, 0, univers);
			assertEquals(b.getMaMatrice().size(),4);
			assertEquals(b.getRegle().getExiste()[0],regle[0]);
			assertEquals(b.getRegle().getExiste()[1],regle[1]);
			assertEquals(b.getRegle().getExiste()[2],regle[2]);
			assertEquals(b.getMaMatrice().get(0),(new Cellule(9,4)));
			assertEquals(b.getMaMatrice().get(1),new Cellule(14,4));
			assertEquals(b.getMaMatrice().get(2),new Cellule(15,4));
			assertEquals(b.getMaMatrice().get(3),new Cellule(18,4));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			fail("Fichier introuvable");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			fail("Erreur de lecture");
		} 
		nom1 = "coucou";
		try {
			b=Jeu.lireFichier(nom1, 0, null);
			fail("Fichier existant");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			fail("Probleme de lecture");
		}
		String nom3 = "lif.lif";
		try {
			b=Jeu.lireFichier(nom3, 0, null);
			fail();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			fail();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			
		}
	}

}
